<template>
  <wx-tables
    :columns="columns"
    title="学部管理"
    :data-source="dataSource"
    :loading="loading"
    :total="total"
    :size.sync="size"
    :page.sync="page"
  >
    <!-- tools -->
    <template #tools>
      <el-button type="primary" class="table-btn" @click="handleOpenForm()">添加学部</el-button>
      <!--      <el-button class="table-btn" icon="el-icon-refresh-right" @click="handleGetTable">刷新</el-button>-->
    </template>
    <template v-slot:oper="record">
      <div class="oper-box">
        <span><el-link type="primary" @click="handleOpenForm(record.row.id,editCon,record.row)">编辑</el-link></span>
      </div>
    </template>
    <wx-dialog
      ref="wx-dialog"
      :visible.sync="formVisible"
      :is-add="isAdd"
      width="500px"
      @ok="handleSaveForm"
    >
      <el-form ref="ruleForm" v-loading="formLoading" :rules="ruleForm" :model="formInfo" label-position="right" label-width="80px">
        <el-form-item label="学部名称" prop="name">
          <el-input v-model="formInfo.name" />
        </el-form-item>
      </el-form>
    </wx-dialog>
  </wx-tables>
</template>
<script>
import WxDialog from '@/components/WxDialog'
import WxTables from '@/components/WxTables'
import TableMixins from '@/components/WxTables/mixins'
export default {
  name: 'Grade',
  components: {
    WxDialog,
    WxTables
  },
  mixins: [TableMixins],
  data() {
    return {
      formInfo: {
        school_id: 1
      },
      editCon: ['name'],
      columns: [
        { config: { type: 'index', width: 100 }, label: '序号' },
        { dataIndex: 'name', label: '学部' },
        { dataIndex: 'class_num', label: '包含班级' },
        { dataIndex: 'oper', label: '操作', slots: true }
      ],
      markId: 'id',
      // 查询表格API
      api: 'api/adminPortal/yearDepartment/getListByCon?level=' + 'class_num',
      // 根据ID markId 查询
      // findApi: '/systemAdmin/getById',
      // 接口前缀 修改
      baseApi: 'api/adminPortal/yearDepartment/',
      ruleForm: {
        name: [
          { required: true, message: '请填写学部名称', trigger: 'blur' }
        ]
      }
    }
  }
}
</script>
<style lang="scss" src="./style/index.scss" scoped/>
